#include "ui_helpers.h"
#include "ui.h"

void Arc1Ani_callback_set_angle(lv_anim_t* a, int32_t v)
{
    ui_anim_user_data_t* usr = (ui_anim_user_data_t*)a->user_data;
    if (v <= 100) {
        lv_arc_set_mode(ui_Arc1, LV_ARC_MODE_REVERSE);
        lv_arc_set_value(usr->target, v);
    }
    else {
        lv_arc_set_mode(ui_Arc1, LV_ARC_MODE_NORMAL);
        lv_arc_set_value(usr->target, 200 - v);
    }
}

void Arc1Ani_callback_free_user_data(lv_anim_t* a)
{
    lv_mem_free(a->user_data);
    a->user_data = NULL;

    _ui_screen_change(&ui_Screen2, LV_SCR_LOAD_ANIM_FADE_ON, 1500, 50, &ui_Screen2_screen_init);
}

void LoginContAni_callback_free_user_data(lv_anim_t* a)
{
    lv_mem_free(a->user_data);
    a->user_data           = NULL;

    LoginContAni_isRunning = 0;
}


void KeyboardAni_callback_set_status(lv_anim_t* a, int32_t v)
{
    ui_anim_user_data_t* usr = (ui_anim_user_data_t*)a->user_data;
    lv_obj_set_y(usr->target, v);

    if (usr->val == 0) {
        Keyboard_isHiding = 0;
    }
    else if (usr->val == 1) {
        Keyboard_isHiding = 1;
    }
}

void KeyboardAni_callback_free_user_data(lv_anim_t* a)
{
    lv_mem_free(a->user_data);
    a->user_data          = NULL;
    KeyboardAni_isRunning = 0;
}


void GroupBtnAni_callback_free_user_data(lv_anim_t* a)
{
    lv_mem_free(a->user_data);
    a->user_data          = NULL;
    GroupBtnAni_isRunning = 0;
}

void friendListAni_callback_set_status(lv_anim_t* a, int32_t v)
{
    ui_anim_user_data_t* usr = (ui_anim_user_data_t*)a->user_data;
    lv_obj_set_y(usr->target, v);

    if (usr->val == 0) {
        friendListAni_isHiding = 0;
    }
    else if (usr->val == 1) {
        friendListAni_isHiding = 1;
    }
}


void friendListAni_callback_free_user_data(lv_anim_t* a)
{
    lv_mem_free(a->user_data);
    a->user_data            = NULL;

    friendListAni_isRunning = 0;
}

void ChatterContAni_callback_free_user_data(lv_anim_t* a)
{
    lv_mem_free(a->user_data);
    a->user_data             = NULL;

    ChatterContAni_isRunning = 0;
}
